<?php
include("../includes/header-member.php");
include("eventSignupFunctions.php");
?>
<title>LazySwim</title>
<script type='text/javascript'>
function confirmation() {
	return confirm("Are you sure you want to sign up for this event?")
}
function confirmation2() {
	return confirm("Are you sure you want to remove yourself from this event?")
}
</script>
</head>

<body>
<div id="page">
    <div id="page-top">
        <div id="page-bottom">
          <div id="header">
                <div id="header-info">
                    <h1>LAZYSWIM</h1>
                    <div class="description">Simplistic Swim System</div>
                </div>
				<!-- Header Goes Here -->
                <?php printHeader(); ?>
				<!-- Header Ends Here -->
                <div id="header-date">Today is <?php echo date('l, F jS, Y'); ?></div>
                <div id="header-cats">
				<!-- Welcome Message Starts Here -->
                    <ul>
					<?php include("../../includes/welcomeBar.php"); ?>
					</ul>
				<!-- Welcome Message Ends Here -->	
                </div>
            </div>
            <div id="main">

                <div id="sidebar">
                    <?php
					// include the corresponding navigation page
                    include("../../includes/navigation.php");
					?>     
                </div>

<!-- main body -->
            
			<div class="featured-post"> 
			
				<div class="post-title"><h2> Event Signup </h2></div>
				<div class="post-entry">
				<h3>Your Registered Events</h3>
				<p><a href="index.php?view=all">View all event registrations</a> | <a href="index.php?view=past">View past registrations only</a> | <a href="index.php?view=upcoming">View upcoming events only</a></p>
				
				<?php 
				if($_GET['view'] == 'all') {
					$registered = usersRegisteredEvents($_SESSION['ls_userid']);
					echo "<p>You were/are currently registered in the following events:</p>\n<hr>";
				} elseif ($_GET['view'] == 'past') {
					$registered = usersPastEvents($_SESSION['ls_userid']);
					echo "<p>You were registered in the following events:</p>\n<hr>";
				} elseif ($_GET['view'] == 'upcoming') {
					$registered = usersUpcomingEvents($_SESSION['ls_userid']);
					echo "<p>You are currently registered in the following upcoming events:</p>\n<hr>";
				} else {
					$registered = usersUpcomingEvents($_SESSION['ls_userid']);
					echo "<p>You are currently registered in the following upcoming events:</p>\n<hr>";
				}

				
				foreach ($registered as $event) {
					displayEventInfo($event);
					echo "<a href='remove.php?eventID=$event' onclick='return confirmation2();'>Remove yourself from this event!</a>";
					echo "<hr>";
				}
				?>
				</div>
				<div class="post-title"><h2> Event Listing </h2></div>
				<div class="post-entry">            

				<p>Please select the meet you wish to view events for.<br>(Only upcoming events are shown)</p>
				<?php createMeetDropdown(); ?>
				
				<?php
				// Display events for selected meet
				if ($meet = $_GET['selectedEvent']) {
					displayEventsForMeet($meet);
				}
				?>
				
				<!-- end of main -->

				</div>
			</div>	
				

             
                <div class="clear"></div>

            </div>
			<!-- Footer Goes Here -->
            <?php include("../../includes/footer.php"); ?>
			<!-- Footer Ends Here -->
        </div>
    </div>
</div>
</body>
</html>